import ala from 'ala'


/*
* 编辑wiki
* @isSaveAs 是否另存为
* @isSaveAs wiki数据
*/
export async function wikiEdit (isSaveAs, wiki, data) {
  if (!wiki) {
    return
  }
  var content = wiki.content
  if (!wiki.content && data) {
    content = data.content
  }
  if (isSaveAs === true && !content) {
    if (!content) {
      ala.error('正文内容不能为空')
    }
    return
  }
  if (ala.strLength(content) < 5) {
    if (isSaveAs === true) {
      ala.error('正文内容不能少于5个字')
    }
    return
  }
  var para = {
    isSaveAs: isSaveAs,
    wiki: wiki
  }
  para.wiki.content = content

  var response = await ala.httpPost('Api/Wiki/Edit', para)
  return response
}











